package com.example.xjtuse_pc.mobilesafe;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.xjtuse_pc.mobilesafe.LostGuid.Setup1Activity;

public class LastFindActivity extends Activity {
private SharedPreferences sp;
    private  TextView phone;
    private ImageView iv_protecting;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        sp=getSharedPreferences("config",MODE_PRIVATE);
        //判断一下，是否做过设置向导，如果没有做过，就跳转到设置向导页面去设置，否则就留着当前的页面
       Boolean result= sp.getBoolean("configed", false);
        String number=sp.getString("safephone","").toString().trim();
        Log.i("join", number);
        if(result) {
            setContentView(R.layout.activity_last_find);
            phone = (TextView) findViewById(R.id.phone_number);
            iv_protecting= (ImageView) findViewById(R.id.iv_protecting);
            phone.setText(number);
            //设置防盗保护的状态
            boolean protecting = sp.getBoolean("protecting", false);
            if(protecting){
                //已经开启防盗保护
                iv_protecting.setImageResource(R.drawable.lock);
            }else{
                //没有开启防盗保护
                iv_protecting.setImageResource(R.drawable.unlock);
            }

        }else {
            Intent intent=new Intent(LastFindActivity.this, Setup1Activity.class);
            startActivity(intent);
            finish();
        }
    }

    /**
     * 重新进入向导页面
     * @param view
     */
    public void reEnterSetup(View view) {
        Intent intent=new Intent(LastFindActivity.this, Setup1Activity.class);
        startActivity(intent);
        finish();
    }
}

